package com.mervin.patterns.adapter.objectadapter;

/***************************************
 * @Auther: mervin
 * @Date: 2020-04-20 23:42
 * @Description: 电压转换器 适配器类
 ***************************************/
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V;

    public VoltageAdapter(Voltage220V voltage220V){
        super();
        this.voltage220V = voltage220V;
    }

    @Override
    public int output5v() {
        int dstv = 0;
        if(voltage220V != null){
            System.out.println("使用对象适配器进行适配...");
            int srcV = voltage220V.output220v();
            dstv = srcV / 44;
            System.out.println("适配完成，输出电压为:" + dstv);
        }
        return dstv;
    }
}
